package com.server.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.server.date.DateType;
import com.server.date.DateUtil;
import com.server.service.ICommonDataService;
import com.server.service.ICorrectPapersService;
import com.server.web.DataVector;
import com.server.web.RequestInput;

/**
 * @author wufeng
 * @date 创建时间：2016年8月22日 上午9:39:34 
 */
@Service("CorrectPapersService")
public class CorrectPapersService implements ICorrectPapersService{
	@Autowired
	private ICommonDataService commonDataService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	
	@Override
	public DataVector<Map<String, Object>> getList(String type, Integer state,
			String user, RequestInput requestInput) {
		String whereStr = "isCorrect = '"+state+"' and state = '1' and isAuto = '0'";
		String sortStr = "distributeTime desc";
		DataVector<Map<String, Object>> listData = commonDataService.getListData("education.v_mark_exam", whereStr, sortStr, requestInput);
		return listData;
	}
	@Override
	public Map<String, Object> getMap(Integer id) {
		String sql = "select * from education.v_mark_exam where id='"+id+"'";
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			map = jdbcTemplate.queryForMap(sql);
		} catch (Exception e) {
			return map;
		}
		return map;
	}
	@Override
	public boolean confirm(String id, Map<String, Object> inputMap,
			String operator) {
		String dateStr = DateUtil.getDateStr(new Date(),DateType.YYYY_MM_DD_HH_mm_ss_SSS); 
		inputMap.put("markTime", dateStr);
		inputMap.put("marker", operator);
		boolean isSuccess = commonDataService.update(operator, "education.mark", "id", id, inputMap);
		return isSuccess;
	}

}
